#region License

/*
    Copyright (c) 2012 Joseph Haluska
    This source is subject to the Microsoft Public License (Ms-PL).
    Please see http://www.microsoft.com/en-us/openness/licenses.aspx for details.
    All other rights reserved.
*/

#endregion License

using System;
using System.Windows.Forms;

namespace NetExceptionReporter
{
    partial class ExceptionReporterForm : Form
    {
        #region Properties

        private ExceptionWindowData _data;

        private ExceptionWindowData Data
        {
            get { return _data; }
            set
            {
                _data = value;

                if (!String.IsNullOrEmpty(_data.Behavior.Title))
                    this.Text = _data.Behavior.Title;

                this.textBoxException.Text = _data.Behavior.OnComposeDetailedDescription(_data.Exception);
                this.warningBox1.Visible = _data.ShuttingDown;
                this.buttonReport.Visible = _data.Behavior.Style.HasFlag(ExceptionWindowStyle.ShowReportButton);
            }
        }

        #endregion Properties

        #region Constructor

        public ExceptionReporterForm()
        {
            InitializeComponent();

            this.Icon = Properties.Resources.ErrorReporter;

            buttonReport.Select();
        }

        public ExceptionReporterForm(ExceptionWindowData data)
            : this()
        {
            Data = data;
        }

        #endregion Constructor

        #region Actions

        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void checkBoxWrap_CheckStateChanged(object sender, EventArgs e)
        {
            this.textBoxException.WordWrap = this.checkBoxWrap.Checked;
        }

        private void buttonReport_Click(object sender, EventArgs e)
        {
            _data.Behavior.OnReportException(_data.Exception);
        }

        #endregion Actions
    }
}